import { applyMiddleware, createStore, combineReducers } from "redux";
// 引入redux-thunk这个中间件. redux-thunk可以帮我们在redux的代码里面写异步代码
import thunk from "redux-thunk";
// import reducer from './reducer'
// 引入调试工具
import { composeWithDevTools } from "redux-devtools-extension";

import headReducer from '../components/Header/redux/reducer'
import footerReducer from "../components/Footer/redux/reducer";
import itemReducer from '../components/Item/redux/reducer'

const reducer = combineReducers({ headReducer, footerReducer, itemReducer });

const store = createStore(reducer, composeWithDevTools(applyMiddleware(thunk)))

store.subscribe(() => {
  const state=store.getState()
  localStorage.setItem('key',JSON.stringify(state.list))
})
export default store
